<!DOCTYPE html>
<html lang="en" xmlns:layout="http://www.w3.org/1999/xhtml"
      layout:decorate="~{admin/adminJs}" xmlns:v-on="http://www.w3.org/1999/xhtml"
      xmlns:v-model="http://www.w3.org/1999/xhtml">
<body layout:fragment="content">
<div id="from">
    <el-form label-width="120px" :model="role"  ref="role" :rules="rules"  style="padding: 15px;">

        <el-form-item label="角色名称:" prop="name">
            <el-input v-model="role.name" style="width: 90%;"></el-input>
        </el-form-item>
        <el-form-item label="角色英文:" prop="roleCode">
            <el-input v-model="role.roleCode" style="width: 90%;"></el-input>
        </el-form-item>
        <el-form-item label="描述:" prop="remark">
            <el-input type="textarea" :rows="2" v-model="role.remark" style="width: 90%;"></el-input>
        </el-form-item>
        <el-row style="text-align: center">
            <el-button type="primary" @click="onSubmit">保存</el-button>
            <el-button @click="resetForm('role')">重置</el-button>
            <el-button @click="cancel()">取消</el-button>
        </el-row>
    </el-form>
</div>
<script>

    var id=RequestUtils.getId();

    var vm=new Vue({
        el: '#from',
        data:function () {
            var role=ajaxGet("/admin/user/role/read",{id:id});
            var rules={
                id:ValidateUtils.required('请输入id!'),
                name:ValidateUtils.required('请输入角色名称!'),
                roleCode:ValidateUtils.required('请输入角色英文!'),
                remark:ValidateUtils.required('请输入描述!'),
                creator:ValidateUtils.required('请输入!'),
                createTime:ValidateUtils.required('请输入!'),
                updatedby:ValidateUtils.required('请输入!'),
                updateTime:ValidateUtils.required('请输入!'),
                isDeleted:ValidateUtils.required('请输入!'),
            };
            return {
                role:role,
                rules:rules
            };
        },
        methods:{
            onSubmit:function () {
                this.$refs['role'].validate(function(valid) {
                    if (valid) {
                        EasyuiUtils.confirmSave("/admin/user/role/save",vm.role,function () {
                            vm.closeParentDialog(true);
                        });
                    } else {
                       EasyuiUtils.alert('请输入必填项!');
                    }
                });

            },
            cancel:function () {
                vm.closeParentDialog();
            },
            closeParentDialog:function(isRefresh){
                window.parent.closeDialog(isRefresh);
            },
            resetForm:function(formName) {
                this.$refs[formName].resetFields();
            }
        }
    });
</script>

</body>
</html>